#ifndef _AME_CHAR_H_
#define _AME_CHAR_H_

struct world_char_inventory_item {
	unsigned short id;
	unsigned short item_id;
	unsigned char quantity;
};

struct world_char {
	unsigned int id;
	char charname[MAX_CHAR_NAME];
	struct client *client;
	struct world_cell *cell;
	struct chain_set  *steps;
	struct chain_set *inventory;
	struct chain_node *position;
	struct chain_node *global_hook;
	char name[16];
	
	/* Mobil */
	struct {
		unsigned sex: 1;
		unsigned class_id : 4;
		unsigned lvl: 4;
		unsigned exp: 32;
		unsigned speed: 8;
		unsigned short max_hp;
		unsigned short max_sp;
		struct world_cell *respawn;
	} props;

	struct {
		unsigned dead: 1;
		unsigned short hp;
		unsigned short sp;
		struct chains_set *effects;
		enum {
			CHA_STAYINGBY,
			CHA_WALKING,
			CHA_ATTACKING
		} action;
		unsigned long nextAction;
	} status;
	
	struct {
		unsigned wspeed: 4; /* Walking speed                                    */
		unsigned aspeed: 4; /* Attack speed                                     */
		unsigned cspeed: 4; /* Casting speed                                    */
		unsigned f_dam:  4; /* Phisical damage 0-100%                           */
		unsigned m_dam:  4; /* Magical damage 0-100%                            */
		unsigned f_def:  4; /* Phisical defence 0-100%                          */
		unsigned m_def:  4; /* Defence from magic 0-100%                        */
		unsigned s_int:  4; /* Intelligence - Magii stat, 2nd Support           */
		unsigned s_dex:  4; /* Dexterity    - Range stat, 2nd magii             */
		unsigned s_str:  4; /* Strength     - Rogue stat,                       */
		unsigned s_vit:  4; /* Vitality     - Tank  stat, Support stat          */
		unsigned s_per:  4; /* Persistance  - 2nd magii, 2nd tank               */
		unsigned s_cha:  4; /* Charisma     - 1st Cute, 1st rogue, 3rd suppoort */
	} stats;

	struct {
		unsigned item_helm;
		unsigned item_larmor;
		unsigned item_harmor;
		unsigned item_boots;
		unsigned item_weapon1;
		unsigned item_weapon2;
	} equiped;
};

inline void char_init(struct client *me);
inline void char_setPosition(struct world_char *c, struct world_cell *cell);
inline void char_sees(struct world_char *me, WorldObject type, void *what);
int char_stop(struct world_char *c);
int char_do(struct world_char *c);
struct world_cell *char_getNextCell(struct world_char *c);
int char_getStatus(struct world_char *c);
void char_shut(struct client *me);

#endif
